package com.mylock;

import org.apache.zookeeper.KeeperException;

import java.util.concurrent.CountDownLatch;

/**
 * @author:wesley
 */
public class MyMainTest {

    private static int thread_num = 5;

    public static CountDownLatch threadCdl = new CountDownLatch(thread_num);

    public static void main(String[] args){

        for (int i = 0; i < thread_num; i++) {
            new Thread(){
                @Override
                public void run() {

                    try {
                        new MyLockService().doService(new MyDoTemplate() {
                            public void doSomeThing() {
                                System.out.println(Thread.currentThread().getName() + "正在做我要做的事情");
                            }
                        });
                    } catch (KeeperException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }.start();
        }

        try {
            threadCdl.await();
            System.out.println("全部执行完毕");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }





}
